package com.zk.mylib

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.gc.logger.LogUtils
import com.zk.lib_service.ServiceManager

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        var recyclerView = findViewById<RecyclerView>(R.id.recyclerview)
        recyclerView.layoutManager=LinearLayoutManager(this)
        var datas= mutableListOf("UI","高仿","功能","知识")
        var homeAdapter = HomeAdapter(datas)
        homeAdapter.setOnItemClickListener { adapter, _, position ->
            var item = adapter.getItem(position) as String
            if(item=="UI"){
                startActivity(Intent(this@MainActivity,MainUIActivity::class.java))
            }else if(item=="高仿"){
                startActivity(Intent(this@MainActivity,MainGaoFangActivity::class.java))
            }else if(item=="功能"){
                startActivity(Intent(this@MainActivity,MainFuncActivity::class.java))
            }else if(item=="知识"){
                startActivity(Intent(this@MainActivity,MainKnowledgeActivity::class.java))
            }

        }
        recyclerView.adapter=homeAdapter


    }
    class HomeAdapter( mutableList: MutableList<String>) : BaseQuickAdapter<String,BaseViewHolder>(R.layout.view_item_home,mutableList) {
        override fun convert(holder: BaseViewHolder, item: String) {
           holder.setText(R.id.tv_title,item)
        }

    }

    override fun onStop() {
        super.onStop()
        LogUtils.e("aaaaaaaaaaaaa","MainActivity  onPause ")
        ServiceManager.getRunServiceInfos(this)
    }
    override fun onDestroy() {
        super.onDestroy()
        LogUtils.e("aaaaaaaaaaaaa","MainActivity  onDestroy ")
        ServiceManager.getRunServiceInfos(this)
    }

}